Neural Network Clustering and Swarm Intelligence-Based Routing Protocol for Wireless Sensor Networks: A Machine Learning Perspective

With no requirement for an established network infrastructure, wireless sensor networks (WSNs) are well suited for applications that call for quick network deployment. Military training and emergency rescue operations are two prominent uses of WSNs. The individual network nodes must carry out routing and intrusion detection because there is no predetermined routing or intrusion detection in a wireless network. WSNs can only manage a certain volume of data, and doing so requires a significant amount of energy to process, transmit, and receive. Since sensors have a modest energy source and a constrained bandwidth, they cannot transmit all of their data to a base station for processing and analysis. Therefore, machine learning (ML) techniques are needed for WSNs to facilitate data transmission. Other current solutions have drawbacks as well, such as being less reliable, more susceptible to environmental changes, converging more slowly, and having shorter network lifetimes. This study addressed problems with wireless sensor networks and devised an efficient clustering and routing algorithm based on machine learning. Results from simulations demonstrate that the proposed system beats previous state-of-the-art models on a variety of metrics, including accuracy, specificity, and sensitivity (0.93, 0.93, and 0.92 respectively).


Introduction
In certain real-time applications, wireless sensor networks (WSNs) [1] ofer advantages, such as size, cost-efectiveness, and easy deployment that make them promising technologies [2]. Sensor nodes are employed in large numbers in WSN applications to monitor a feld and gather data that are then sent to the base station for processing [3,4]. As a result, controlling such a vast number of nodes necessitates the development of a scalable and efcient algorithm. WSNs can also change dynamically due to external factors or according to the design plans of the system developers. As a consequence, routing methods, localization, latency, cross-layer design [5], coverage, quality of service, fault detection, link quality, and other aspects of the system may be afected [6]. Depending on the dynamic network, it may be necessary to depreciate nonessential confgurations. However, traditional WSN systems are explicitly coded, and as a result, they cannot be correctly implemented in a dynamic environment. In machine learning (ML), improvements or learning occur without explicit programming based on knowledge or studies [7,8].
By using machine learning, machines became more reliable, more accurate, and less expensive. Models are created using machine learning, allowing for more complex data to be analyzed automatically, swiftly, and precisely. ML [9][10][11][12] is well known for its ability to provide generic resolutions using an approach that learns to improve its efciency over time. As a result, supervised learning, semisupervised learning, unsupervised learning, and reinforcement learning are all part of machine learning. WSN difculties have been solved using recent improvements in machine learning [1]. Because of their transdisciplinary nature, WSNs are important for engineering, medicine, and computers ( Figure 1). Tey assist in gaining access to and obtaining useful information from the vast quantities of data produced by sensors without requiring human intervention or reprogramming. WSNs' performance improves via machine learning, which eliminates the necessity for human interference or reconfguration. Tey use cloud computing and big data processing in addition to the Internet of Tings (IoT) and machine-to-machine integration [1].

Challenges in WSNs and Machine Learning Techniques.
Normally, sensor nodes are positioned in dangerous regions where the network is left to operate autonomously without human intervention. When constructing WSNs, researchers must take into consideration factors such as battery power limitations, memory constraints, connection failure, dynamic topology changes, and decentralized control. In this section, we look at how machine-learning techniques may be used to address various problems in wireless sensor networks. Tree categories are used to group WSN challenges. Focus should be placed on three primary areas: functioning, future challenges, and security and other issues [13]. Below, each of these problems is discussed.

Functional Challenges.
Additionally, various machine learning algorithms address clustering and data aggregation, energy harvesting, MAC management, location, event detection and query processing, mobile sink, object tracking, trafc regulation, coverage, and network issues, while traditional routing systems handle routing issues.

Aggregation and Clustering of Data.
Te direct delivery of sensed data to the sink node is a need in WSNs in large-scale networks. Te use of clustering can allow for the direct transmission of data to the sink node, resulting in considerable energy savings. Additionally, selecting efcient cluster heads can contribute to the use of low-energy clustering. Cluster nodes in a cluster head (CH) gather data from each other.

Query Processing and Event Detection.
It is a common requirement in many WSN applications that the user detects activity around moving objects and relays this back to the user. In addition, these activities usually take place in different places and last an indeterminate period. WSNs may be observed in three ways: event-driven, continuous-monitoring, and query monitoring. With limited resource capability, machine learning may assist in delivering efective query processing and solutions, thus identifying events, and analyzing event authenticity. It is still necessary to create improved event detection and query processing algorithms utilizing various machine learning approaches. Although the academic community has taken an active interest in these areas [14], there is still a gap.

Energy
Harvesting. Using solar energy to power sensor nodes in an open environment has emerged as a viable option for providing the nodes with enough power in a longterm manner. It is the process of converting energy from the environment into electrical energy. Several obstacles may arise in the efective integration of energy harvesting technologies into WSNs [15][16][17][18][19][20].

Object Tracking and Localization.
Localization is a procedure for detecting the global position of a sensor node utilizing GPS technology, which is prohibitively expensive for large-scale networks. Most WSN applications need to locate their sensor nodes geographically, which becomes an issue.
1.1.6. Mobile Sink. When sensors collect data through a WSN, the data are transmitted to sink nodes in an isolated or distributed manner. In the vicinity of the sink nodes, the nodes become bottlenecks, resulting in hotspots. Tus, mobile sinks have emerged as a concept in WSN research. Te information is collected by the mobile sink as it moves from one sensor node to the next. Mobile sinks gather information from rendezvous points rather than visiting each sensor node. Since it is difcult to visit every sensor node, scheduling the mobile sink is a research focus. Te information is sent to RPs via other sensor nodes. To eliminate delays, numerous mobile sinks are sometimes employed, although this is not cost-efective. Using a mobile sink, ML can aid in discovering optimum RPs and avoiding delays.

Congestion Control.
In WSNs, congestion can occur when data quantities exceed the available bandwidth. Tis happens when the data link transmits more data than the channel can handle. As congestion is usually found at the connections or nodes level, it afects latencies, packet losses, and quality of service, as well as total energy consumption. ML algorithms can accurately predict trafc, remove end-toend delays, and dynamically modify transmission ranges based on packet arrival rates at nodes and bit error transmission rates at links. Lower packet error rates and collisions between nodes can cause congestion at the node and link levels.
1.1.8. Coverage and Connectivity. In WSNs, coverage and connection are key issues. WSNs are often deployed in a deterministic or random manner in a given area. It is connected with a BS station or relay node if it can communicate directly with the BS station or relay node. A sensor node's coverage is the extent to which it is able to monitor a particular area. Te nodes will have a gap if there are not enough sensors in the region. As connectivity problems arise, ML can be used to determine how many sensors are needed to cover the target region and adjust the route dynamically as necessary.
Since the nodes of wireless sensor networks (WSNs) solely run on battery power, energy saving is one of the main issues with these networks. A network of sensor nodes serves as the foundation of a WSN design. Te development of efective and reliable communication protocols is essential for overcoming WSN challenges and maintaining the network for a long time. Traditional technologies can solve a lot of WSN problems, but they might not be able to produce a good enough mathematical model to anticipate network behavior. In order to characterize system behavior for challenging tasks like routing, data fusion, localization, and object tracking, low-complexity mathematical models are used. With the help of machine learning techniques, this study aims to create a cluster and routing protocol for WSNs that takes into account concerns such as battery life, adaptability to environmental changes, reliability, convergence speed, and network lifetime. Te amount of energy required for data gathering and distribution is drastically reduced by using hierarchical routing protocols based on swarm intelligence in conjunction with neural networkbased clustering techniques. Using a variety of important criteria, this technique is evaluated against several clustering and routing strategies.

Key Highlights.
Te goals of this study, which focuses on improving WSN routing, are as follows: (i) Create a clustering and routing mechanism for WSNs based on ML (ii) Create a reliable and efective model to address WSN challenges and sustain the network for a long time (iii) Neural network-based and swarm intelligencebased techniques are utilized, respectively, for clustering and routing (iv) According to the experimental analysis, the suggested model performs better and uses less energy in WSNs Organization of the paper: We provided an overview of a WSN and its challenges in Section 1. Te rest of the paper is as follows: Section 2 presents a literature review, Section 3 describes the overall methodology, Section 4 depicts the performance analysis, and fnally, the paper is concluded in Section 5.

Related Works
As many researchers attempt to investigate the feld of wireless networks and their integration with machine learning for future purposes, some research is organized into categories, such as classical-based machine learning, optimization-based machine learning, and neural networkbased machine learning.

Classical-Based Techniques.
To calculate the number of clusters, traditional approaches employ a statistical technique. To replace a CH with traditional methods, a threshold is built into a method that assesses the number of nodes with remaining energy or their energy consumption, which causes the network to recluster [16]. In cluster-based routing protocols, traditional techniques focus on how to pick cluster heads. Pal Singh and Chander Sharma [17] proposed a method for improving the routing protocol. Te Voronoi diagram is then generated with the cluster head as the center based on the predictions made in accordance with the estimated total energy usage. Cluster heads are then calculated every round according to the predicted total energy usage. Tis reduces the energy consumed for intracluster communication, as the nodes in the Voronoi diagram form a cluster. Te multihop routing protocol uses an ant colony algorithm to optimize the node-to-node routing by having a cluster head located near the BS that accepts and routes data from the cluster's nodes. MATLAB simulations indicate that the protocol is superior to LEACH in extending the lifetime of WSNs, as well as in improving energy efciency per node each round. As Ahmad et al. (2015) [18] discovered, by considering the intracluster distance, intercluster communication, and the farthest cluster head (CH) for a cluster Computational Intelligence and Neuroscience rather than the closest cluster head (CH) for the cluster, the lifetime of a network can be extended. [19] provided a method for determining the path from each cluster's CH to BS. Once the frefy is switched on, it provides an alternate route from the CH to the BS. Each frefy is the same size as the number of CHs with an additional spot for the BS. Each point in the CH's routing data to the BS represents its next hop. Every time the lower-brightness frefy approaches the higher-brightness frefy, each frefy's position is updated. Te procedure is repeated until the conditions are met. In the ftness function, the energy for the next residual hop, the degree of a node, the distance between the CH and the next hop, and the number of CH members making up the next hop are considered.

Optimization-Based Techniques. Shokouhifar and Jalali
Rao [20] proposed a particle swarm-based optimization clustering approach with a mobile sink for wireless sensor networks. Tis algorithm employs the virtual clustering strategy throughout the routing step, which utilizes the particle swarm optimization algorithm. Residual energy and node location are the most important factors to consider when selecting a cluster head. Te control approach is used by the mobile sink to collect data from the cluster head. Comprehensive simulated results show that our proposed routing technique consumes less energy, has a longer network lifetime, and has a lower transmission delay than several existing commonly used routing methods.
Radhika and Sivakumar [21] suggested an enhanced artifcial bee colony optimization-based clustering technique (IABCOCT) that ensures optimal clustering and CH selection by combining the advantages of the grenade explosion and the Cauchy operator. Tis provides a lot of investigation and enhancement to the level of analysis and exploration in the observer bee and scout bee phases, which helps determine the optimal cluster heads. Using this clustering process improves the cluster head selection accuracy while also lowering the node energy consumption.

Neural Network-Based Techniques.
Using SVM as the goal, Anand et al. [22] designed a decision function based on statistical learning theory. Tis decision function has a simple implementation at the cluster nodes to detect abnormal sensors since it allows for low-resolution detection. Compared to the newest fault detection algorithm for WSNs, SVM is more efective at detecting faults in WSNs through an experimental investigation.
Te synthetic minority oversampling technique (SMOTE) suggested by Nayak et al. [23] is used to balance the dataset before training the intrusion detection classifcation through the random forest algorithm. Random forest accounts for 92.39% of the accuracy in a benchmark intrusion dataset, which is higher than that of other similar algorithms. Additionally, random forest paired with the SMOTE has grown the accuracy to 92.57% after oversampling the minority samples.
Using multilayer perceptron neural networks (MLPNN) and radial basis function neural networks (RBFNN) to construct an analysis framework for localization in WSNs, Raj [24] compared and analyzed them. As a result, the received signal strength indicator (RSSI) from three anchor nodes with fxed placements was used to determine whether the static sensors were within the 100 100 m 2 grid. Simulation results suggested that the MLPNN performs better than the RBFNN.

Data Transmission Model.
At frst, sensor nodes are scattered randomly across a sensor feld and powered by fullcapacity batteries. Te network is made up of sensor nodes with limited power. Te data gathered by each sensor are typically linked with the data of surrounding sensors, resulting in the delivery of data relating to each sensor to the BS for evaluation or consideration for making choices. We consider periodic sensing with the same time interval for all sensors. We employ a fxed clustering mechanism that leads to cluster selection as a result of a novel clustering approach [25]. Within each cluster, a node is regularly chosen to serve as a communication hub (CH), enabling communication to and from the cluster (Figure 2).

Model for Attaining Energy.
A radio transceiver's energy consumption is estimated by using the following energy model [26]. Basically, a transmitting node sends each packet to one or more receivers within its vicinity and then calculates how much of that energy is consumed by each node.
C � C t + nC r +(N − n)C h r. (1) Because C t and C r are dependent on the number of neighbors who must receive the data, n is the number of neighbors who must be included in the transmission, and C t and C r are the energy required to transmit and receive the packet, respectively. According to the paradigm provided in [27], C t or C r denotes the amount of energy necessary for only decoding the packet header for a distance d and a k-byte message.

Clustering Using NN.
We approach the energy-aware routing problem via an LP formulation. Its goal is to identify the node with the greatest amount of remaining energy and include it in the best path while minimizing network costs. Assume that the CH nodes range from 1 to n, where n is the number of CH sensor nodes, and that the base station node is 0.

(5)
Te frst and second constraint sets the maximum quantity of data that can be shared among two nodes, S i and S j , while the third ensures that each node in the network has a minimal lifespan and controls the maximum power usage [14,[28][29][30].

Setup Phase.
Here, an energy-conscious path is built using a swarm intelligence algorithm based on cluster selection and cluster creation.

Cluster Head Selection.
To prevent the network from being overloaded with energy consumption throughout the network lifecycle, several clustering algorithms provide evenly dispersed clusters with constant average cluster sizes. However, we present a cutting-edge neural network-based coverage-aware clustering method [31]. Equation (3) allows for the selection of cluster head nodes. Cluster head nodes are congested in the network's more populated areas, but not in its sparsely populated ones. Given that the proposals include three layers-the input layer, the competition layer, and the output layer-a neural network with three layers attempts to further decrease the lifetime of expensive sensors in sparsely covered areas.
Tey have a number of benefts, including fexibility, simplicity, parallelization, speed, and adaptability. Tey can learn and have been applied to a range of problems. Te competitive learning theory is applied to a two-layer feedforward neural network in Figure 3. Te sensor nodes that compete for CH provide input patterns to the input nodes. Each output node is coupled with a cluster and has a weight W j , j = 1, 2, . . ., m, where m is the number of clusters. It is suggested that the CH selection technique involves adaptive learning in each neuron in the competitive layer because only the neuron with the lowest E D i value succeeds in getting activated or fring. Learning is determined by the learning pace, which directly afects convergence. If it is set to 0, there is no learning. Te prototype vector is given to the input if it is set to one. Between the preceding vector value and the remaining input pattern selections, a new vector position is created. In general, the learning rate might be constant or fuctuate (Algorithm 1).

Routing Using Swarm
Intelligence. It may be used to represent the nth particle (P i ) in the n-dimensional population as a function of a bird's or fsh's behavior in a group. Particles adjust their location in response to a group's position and velocity. In the case of an n D-dimensional population, the ith particle (P i ) is represented as follows: A ftness function is applied to every object's location to evaluate the accuracy of the response it supplies in the present iteration. Tracking the particle's personally best position (Pbest) and the particle's overall best position (Wbest) can provide the particle with its globally best position (Gbest). V id and X id can be modifed, and the velocity and location of each particle are as follows: Te weight of inertia can be determined using the following formula, where inertia weight is w, c 1 and c 2 are accelerating coefcients, and r 1 and r 2 are arbitrary variables in the [0, 1] range.
Te ideal number of CHs is generated using a suggested PSO method. Te suggested PSO algorithm's problem is a time-varying equation with a new value for each iteration. Furthermore, if a sensor node is within its communication range, it can be used as a cluster head. Te essential knowledge paradigm is similar to traditional algorithms, such as LEACH. Every new cycle begins with information sent from each node to the cluster head. As soon as the information is collected by the cluster head, repeated data are deleted, and the actual data are sent to the subsequent hop, which is generally the base station or another cluster head. (Algorithm 2)

Results
Te proposed model (NNC-PSOR) is compared to state-ofthe-art models, such as WCDT, FCM, LEACH, PEACH, ANFIS, LEACH-GA, and FBR on key parameters such as network lifetime, clustering speed, accuracy, quality, sensitivity, randomness in results, performance, energy management, and security. Table 1 shows the simulation network lifetime based on the number of iterations (6000) based on diferent models. We employ a 400 400 pixel wide, 50 m        Figure 6: (a) Network models vs randomness of results, (b) network models vs performance, (c) network models vs energy management, and (d) network models vs security. 8 Computational Intelligence and Neuroscience outperforms LEACH, PEACH, and other existing approaches by more than 90%. Figure 5 shows a graphical representation of model attributes, such as clustering speed, accuracy, quality, and sensitivity. Te graphical depiction of several models with parameters such as unpredictable results, performance, energy management, and security is shown in Figures 6(a)-6(d).

Conclusion
Tis paper demonstrates the usefulness of clustering and routing using machine learning in this study, resulting in a considerable increase in the network lifetime and performance of WSNs. When analyzing a network via simulation compared to existing models, the integration of neural networks and particle swarm optimization allows for much longer network life. As technologies are being revolutionized in an advanced way, the integration of several models instead of going in one direction can increase performance. However, machine learning algorithms cannot automatically make reliable predictions, as they must learn from historical data. Other researchers are encouraged to expand on this work to develop even more efective clustering and routing methods for WSNs. Increasing the size of the information also increases the amount of energy used to process the data, which then afects the performance. With the simulation results, swarm intelligence outperforms standard techniques under a variety of network conditions, providing a high degree of fexibility and efciency. In order to further examine the performance, real-time data are required, which is one of the restrictions. Te application of this model with current and real-time data will be required in the future to further boost efciency in order to get beyond these restrictions.

Data Availability
Te datasets used and/or analyzed during the current study are available from the corresponding author on reasonable request.